//
//  Copyright (c) 2013年 weiwang. All rights reserved.
//
#import "UIColor+Hex.h"
#import "NSDate+Utilities.h"

#ifdef DEBUG
#define NSLog(format, ...) printf("\n[%s] %s [第%d行] %s\n", [[[NSDate date] stringWithFormat:@"YYYY-MM-dd hh:mm:ss:SSS"] UTF8String], __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else
#define NSLog(format, ...)
#endif
//device
#define UI_SINGLELINE (((int)(100/(UI_SCREEN_SCALE)))/100.0)
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#define SYSTEM_VERSION_7_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
#define SYSTEM_VERSION_8_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
#define SYSTEM_VERSION_9_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0"))
#define SYSTEM_VERSION_10_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0"))
#define IS_RETINA  ([[UIScreen mainScreen] scale] != 1)
#define UI_SCREEN_SCALE ([[UIScreen mainScreen] scale])
#define UI_SCREEN_SIZE ([UIScreen mainScreen].bounds.size)
#define UI_SCREEN_SIZE_FOR_PORTRAIT CGRectMake(0, 0, MIN(UI_SCREEN_SIZE.width, UI_SCREEN_SIZE.height), MAX(UI_SCREEN_SIZE.width, UI_SCREEN_SIZE.height))
#define IOS_7_0 @"7.0"
#define IOS_8_0 @"8.0"
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(320*UI_SCREEN_SCALE, 480*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(320*UI_SCREEN_SCALE, 568*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(375*UI_SCREEN_SCALE, 667*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(414*UI_SCREEN_SCALE, 736*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhoneX     ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(375*UI_SCREEN_SCALE, 812*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define SupportInterface (UIInterfaceOrientationMaskPortrait)
#ifdef iPad
  #define UNIVERSAL(iPhoneValue,iPadValue) (iPad?iPadValue:iPhoneValue)
#endif
#define CoverPixelFrom6Plus(px) px * ((iPhone6 || iPad || iPhone6Plus) ? 1 : 0.66)
#define UI_NAVIGATION_BAR_HEIGHT    64
#define UI_TOOLBAR_HEIGHT           44
#define UI_TAB_BAR_HEIGHT           49
#define UI_STATUS_BAR_HEIGHT        20
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
#define kScreenWidth  [[UIScreen mainScreen] bounds].size.width
#define kNumberKeyBoardMaxHeight 226
#define kDefaultBoardMaxHeight 271


//font
#define UI_NORMAL_FONT(fontSize) [UIFont systemFontOfSize:fontSize]
#define UI_HILIGHT_FONT(fontSize) [UIFont systemFontOfSize:fontSize]
#define UI_BOLD_FONT(fontSize) [UIFont boldSystemFontOfSize:fontSize]
#define kButtonTitleFont      [UIFont systemFontOfSize:14]
#define kItemTitleFont      [UIFont systemFontOfSize:15]

#define LocalString(string) NSLocalizedString(string, nil)

//Color
#define UI_COLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define UI_COLOR_A(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

#define kHistoryBtnColorNormal              kThemeBlueColor
#define kHistoryBtnBorderColorNormal        [UIColor colorWithHex:0x9bcefe]
#define kHistoryBtnBorderColorHighlight     [UIColor colorWithHex:0x176ccc]
#define kHistoryBtnTitleColorNormal         [UIColor colorWithHex:0xb0dcff]
#define kHistoryBtnTitleColorHighlight      [UIColor colorWithHex:0x176ccc]
#define kVoiceBtnTitleColorNormal           [UIColor whiteColor]
#define kVoiceBtnTitleColorHighlight        [UIColor colorWithHex:0x176ccc]
#define kCheckWifiTextColor                 [UIColor colorWithHex:0x333333]
#define kCheckWifiButtonColor               [UIColor colorWithHex:0x666666]
#define ControllerBackgroundColor           [UIColor colorWithHex:0xFAFAFA]
#define kSingleLineColor                    [UIColor colorWithHex:0xdddddd]
#define MoreBackgroundColor                 [UIColor colorWithHex:0xEEEEEE]
#define kSeparateViewBackgroundColor        [UIColor colorWithHex:0xF8F8F8]

#define kTextBarItemColorNormal [UIColor colorWithHexString:@"666666"]
#define kTextBarItemColorHilight [UIColor colorWithHexString:@"bbbbbb"]
#define kTextFieldBackColor [UIColor colorWithHexString:@"83d8ff"]
#define kTextFieldColor [UIColor colorWithHexString:@"5eb1ff"]
#define kTextFieldBackLabelColor [UIColor colorWithHexString:@"003f9e"]
#define kPlaceHolderLabelColor [UIColor colorWithHexString:@"007edd"]
#define kTextFieldBackHightColor [UIColor colorWithHexString:@"44b8fe"]
#define KTextFieldBackColor [UIColor colorWithHexString:@"004ec4"]
#define kTextFieldTextColor [UIColor colorWithHexString:@"ffffff"]
#define kTextFieldTextHightColor [UIColor colorWithHexString:@"48b9ff"]

#define kAccountBackgroundColor           [UIColor whiteColor]
#define kAccountTextFieldTextColor        [UIColor whiteColor]
#define kAccountTextFieldBackgroundColor  [UIColor colorWithHexString:@"44b8fe"]
#define kAccountTextFieldHintColor        [UIColor colorWithHexString:@"9ddbfb"]
#define kAccountLabelTextColor            [UIColor colorWithHexString:@"48a8f7"]
#define kAccountTextFieldCursorColor      [UIColor colorWithHexString:@"b9e4ff"]


#define kHasContentColor [UIColor colorWithHex:0x333333]
#define kInvalidContentColor [UIColor colorWithHex:0xb2b2b2]

#define kActualXGapBaseIphone6P(x) kScreenWidth * x / 414 / 3
#define kActualYGapBaseIphone6P(y) kScreenHeight * y / 736 / 3

#define UI_FONT(fontSize) [UIFont fontWithName:@"FZLTXIHJW--GB1-0" size:fontSize]

